window.bpData = {
    bpInfo: []
}

function brandListDDB(callback) {
    $.ajax({
        url:"/getBrandType",
        method:"get",
        dataType:"json",
        success:function (rel) {
            window.bpData.bpInfo = rel.data
            let str = '<option value="">请选择</option>';

            rel.data.forEach(function (brand,i) {
                str += '<option value="'+brand.brandId+'">'+brand.brandName+'</option>';
            })
            $(".dfBrand").html(str);
            if (callback){
                callback();
            }
        }
    })
}

function productTypeListDDB() {
    let bpInfo = window.bpData.bpInfo;
    let types = {};
    let brandId = $(".dfBrand option:selected").val()
    let str = '<option value="">请选择</option>';
    for (let i = 0; i < bpInfo.length; i++) {
        if ((bpInfo[i].brandId+"") === brandId) {
            types = bpInfo[i].types;
            break;
        }
    }
    if (brandId !== "" && brandId != null) {
        types.forEach(function (type, i) {
            str += '<option value="' + type.typeId + '">' + type.typeName + '</option>';
        })
    }
    $(".dfProduct").html(str);
}

